/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.fhhof.datebook.user.domain;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 *
 * @author Sumedh
 */
@Entity
@Table(name = "dbeventdetails")
@NamedQueries({
    @NamedQuery(name = "Eventdetails.findAll", query = "SELECT e FROM Eventdetails e"),
    @NamedQuery(name = "Eventdetails.findByIntEventID", query = "SELECT e FROM Eventdetails e WHERE e.intEventID = :intEventID"),
    @NamedQuery(name = "Eventdetails.findByDtEventdate", query = "SELECT e FROM Eventdetails e WHERE e.dtEventdate = :dtEventdate"),
    @NamedQuery(name = "Eventdetails.findByStrEventdescription", query = "SELECT e FROM Eventdetails e WHERE e.strEventdescription = :strEventdescription"),
    @NamedQuery(name = "Eventdetails.findByStrComments", query = "SELECT e FROM Eventdetails e WHERE e.strComments = :strComments"),
    
    @NamedQuery(name = "Eventdetails.findByEventFreq", query = "SELECT e FROM Eventdetails e WHERE e.intUserID.intUserID = :intUserID AND e.intFrequencyID.intFrequencyID = :intFrequencyID order by e.dtEventdate ASC"),

    @NamedQuery(name = "Eventdetails.findByIntUserIDandIntEventtypeID", query = "SELECT e FROM Eventdetails e WHERE e.intUserID.intUserID = :intUserID AND e.intEventTypeID.intEventtypeID = :intEventtypeID"),
    @NamedQuery(name = "Eventdetails.findByDates", query = "SELECT e FROM Eventdetails e WHERE e.intUserID.intUserID = :intUserID AND e.dtEventdate >= :dtEventdateStart AND e.dtEventdate <= :dtEventdateEnd ORDER BY e.dtEventdate")})

    public class Eventdetails implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "intEventID", nullable = false)
    private Integer intEventID;
    @Basic(optional = false)
    @Column(name = "dtEventdate", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date dtEventdate;
    
    @Basic(optional = false)
    @Column(name = "strEventdescription", nullable = false, length = 128)
    private String strEventdescription;
    
    @Column(name = "strComments", length = 512)
    private String strComments;
    
    @JoinColumn(name = "intFrequencyID", referencedColumnName = "intFrequencyID", nullable = false)
    @ManyToOne(optional = false)
    private Eventfrequency intFrequencyID;
    
    @JoinColumn(name = "intEventTypeID", referencedColumnName = "intEventtypeID", nullable = false)
    @ManyToOne(optional = false)
    private Eventtype intEventTypeID;
    
    @JoinColumn(name = "intUserID", referencedColumnName = "intUserID", nullable = false)
    @ManyToOne(optional = false)
    private Userdetails intUserID;
    @Transient
    private String strErrorMessage;
    @Transient
    private String strTime;
    
    @Transient
    private Boolean autoGenerated;
    
    @Transient
    private Boolean readOnly;
    
    public Eventdetails() {
    	this.autoGenerated = false;
    	this.readOnly = false;
    }

    public Eventdetails(Integer intEventID) {
        this.intEventID = intEventID;
    }

    public Eventdetails(Integer intEventID, Date dtEventdate, String strEventdescription) {
        this.intEventID = intEventID;
        this.dtEventdate = dtEventdate;
        this.strEventdescription = strEventdescription;
    }

    public Integer getIntEventID() {
        return intEventID;
    }

    public void setIntEventID(Integer intEventID) {
        this.intEventID = intEventID;
    }

    public Date getDtEventdate() {
        return dtEventdate;
    }

    public void setDtEventdate(Date dtEventdate) {
        this.dtEventdate = dtEventdate;
    }

    public String getStrEventdescription() {
        return strEventdescription;
    }

    public void setStrEventdescription(String strEventdescription) {
        this.strEventdescription = strEventdescription;
    }

    public String getStrComments() {
        return strComments;
    }

    public void setStrComments(String strComments) {
        this.strComments = strComments;
    }

    public Eventfrequency getIntFrequencyID() {
        return intFrequencyID;
    }

    public void setIntFrequencyID(Eventfrequency intFrequencyID) {
        this.intFrequencyID = intFrequencyID;
    }

    public Eventtype getIntEventTypeID() {
        return intEventTypeID;
    }

    public void setIntEventTypeID(Eventtype intEventTypeID) {
        this.intEventTypeID = intEventTypeID;
    }

    public Userdetails getIntUserID() {
        return intUserID;
    }

    public void setIntUserID(Userdetails intUserID) {
        this.intUserID = intUserID;
    }

    public String getStrErrorMessage() {
        return strErrorMessage;
    }

    public void setStrErrorMessage(String strErrorMessage) {
        this.strErrorMessage = strErrorMessage;
    }


    public String getStrTime() {
        return strTime;
    }

    public void setStrTime(String strTime) {
        this.strTime = strTime;
    }

    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (intEventID != null ? intEventID.hashCode() : 0);
        return hash;
    }

    public Eventdetails copy(){
    	Eventdetails event = new Eventdetails();
    	event.dtEventdate = this.dtEventdate;
    	event.intEventTypeID = this.intEventTypeID;
    	event.intFrequencyID = this.intFrequencyID;
    	event.intUserID = this.intUserID;
    	event.strComments = this.strComments;
    	event.strEventdescription = this.strEventdescription;
    	event.intEventID = -1;
    	return event;
    }
    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Eventdetails)) {
            return false;
        }
        Eventdetails other = (Eventdetails) object;
        if ((this.intEventID == null && other.intEventID != null) || (this.intEventID != null && !this.intEventID.equals(other.intEventID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "de.fhhof.datebook.user.domain.Eventdetails[intEventID=" + intEventID + "]";
    }


	public Boolean getReadOnly() {
		return readOnly;
	}

	public void setReadOnly(Boolean readOnly) {
		this.readOnly = readOnly;
	}

	public Boolean getAutoGenerated() {
		return autoGenerated;
	}

	public void setAutoGenerated(Boolean autoGenerated) {
		this.autoGenerated = autoGenerated;
	}
}
